<template>
    <div>
        <!--查询条件部分  searchmap -->
        <el-form ref="form" :inline="true" label-width="80px">
            <el-form-item label="名称">
                <el-input v-model="searchMap.userName" placeholder="名称"></el-input>
            </el-form-item>

            <!--<el-form-item label="品牌的首字母" label-width="100px">
                <el-input v-model="searchMap.hobby"  placeholder="品牌" ></el-input>
            </el-form-item>-->

            <el-form-item>
                <el-button type="primary" @click="fetchData()">查询</el-button>
            </el-form-item>
        </el-form>

        <!--table 展示区-->
        <template>
            <el-table
                    :data="tableData"
                    border style="width: 100%">
                <el-table-column
                        prop="id"
                        label="线索id"
                        width="180">
                </el-table-column>
                <el-table-column
                        prop="userName"
                        label="通知用户"
                        width="180">
                </el-table-column>
                <el-table-column
                        prop="notify"
                        label="通知内容"
                        width="180">
                </el-table-column>
                <el-table-column
                        prop="createTime"
                        label="通知时间" :formatter="timeFormat">
                </el-table-column>

            </el-table>
        </template>

        <div class="pagination-container">
            <!--分页插件 -->
            <el-pagination
                    class="pagiantion"
                    @size-change="sizeChange"
                    @current-change="fetchData"
                    :current-page.sync="searchMap.page"
                    :page-sizes="[5, 10, 15, 20]"
                    :page-size="searchMap.size"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </div>


    </div>
</template>

<script>
    export default {
        name: "list",
        data(){
            return{
                tableData:[
                    {"id":1,"userName":'张三',"notify":"张三您好，您提交的线索1已办结","createTime":'2023-11-07 12:12:12'},
                    {"id":1,"userName":'李四',"notify":"李四您好，您提交的线索2办结失败","createTime":'2023-11-07 12:12:12'}
                ],
                total: 10,
                searchMap:{
                    page:1,
                    size: 5
                },
                dialogVisible :false,
                pojo:{}
            }
        },
        created(){
            //设置全局token
            const  token= localStorage.getItem("token");
            this.axios.defaults.headers.common['token']= token;
            this.fetchData();
        },
        methods:{

            onInput(){
              this.$forceUpdate()
            },
            timeFormat(row, column) {
                //日期格式化
                let datac = row[column.property];
                var time = new Date(datac);
                var year = time.getFullYear()
                var month = time.getMonth() + 1
                var date = time.getDate()
                var hours = time.getHours()
                var minutes = time.getMinutes()
                var seconds = time.getSeconds()

                function add0(m) {
                    return m < 10 ? '0' + m : m
                }

                var startTime = add0(year) + '-' + add0(month) + '-' + add0(date) + ' ' + add0(hours) + ':' + add0(minutes) + ':' + add0(seconds)
                return startTime
            },
            sizeChange(v){
                this.searchMap.size = v;
                this.fetchData();
            },
            fetchData(){
                /*const that=this;
                this.axios.post("/api/notify/notifyList",this.searchMap).then(function (resp) {
                    if(resp.data.code == -1){
                        this.$router.push("login")
                    }else{
                        that.tableData = resp.data.data.rows;
                        that.total = resp.data.data.total;
                    }
                })*/
            },
        }
    }
</script>

<style scoped>

</style>
